{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Deep Learning"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T21:57:51.791723Z",
     "start_time": "2017-05-08T21:57:49.969898Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from collections import namedtuple\n",
    "pd.set_option(\"display.max_rows\",35)\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T21:57:52.833645Z",
     "start_time": "2017-05-08T21:57:51.793317Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "kdd_train_2labels = pd.read_pickle(\"dataset/kdd_train_2labels.pkl\")\n",
    "kdd_test_2labels = pd.read_pickle(\"dataset/kdd_test_2labels.pkl\")\n",
    "\n",
    "#y_train_labels = pd.read_pickle(\"dataset/kdd_train_2labels_y.pkl\")\n",
    "#y_train_labels = pd.read_pickle(\"dataset/kdd_train_2labels.pkl\")\n",
    "#y_test_labels = pd.read_pickle(\"dataset/kdd_test_2labels_y.pkl\")\n",
    "\n",
    "output_columns_2labels = ['is_Attack','is_Normal']\n",
    "\n",
    "from sklearn import model_selection as ms\n",
    "from sklearn import preprocessing as pp\n",
    "\n",
    "x_input = kdd_train_2labels.drop(output_columns_2labels, axis = 1)\n",
    "y_output = kdd_train_2labels.loc[:,output_columns_2labels]\n",
    "\n",
    "ss = pp.StandardScaler()\n",
    "x_input = ss.fit_transform(x_input)\n",
    "\n",
    "#le = pp.LabelEncoder()\n",
    "#y_train = le.fit_transform(y_train_labels).reshape(-1, 1)\n",
    "#y_test = le.transform(y_test_labels).reshape(-1, 1)\n",
    "\n",
    "y_train = kdd_train_2labels.loc[:,output_columns_2labels].values\n",
    "\n",
    "x_train, x_valid, y_train, y_valid = ms.train_test_split(x_input, \n",
    "                              y_train, \n",
    "                              test_size=0.1)\n",
    "#x_valid, x_test, y_valid, y_test = ms.train_test_split(x_valid, y_valid, test_size = 0.4)\n",
    "\n",
    "x_test = kdd_test_2labels.drop(output_columns_2labels, axis = 1)\n",
    "y_test = kdd_test_2labels.loc[:,output_columns_2labels].values\n",
    "\n",
    "x_test = ss.transform(x_test)\n",
    "\n",
    "#x_train = np.hstack((x_train, y_train))\n",
    "#x_valid = np.hstack((x_valid, y_valid))\n",
    "\n",
    "#x_test = np.hstack((x_test, np.random.normal(loc = 0, scale = 0.01, size = y_test.shape)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T21:57:53.724768Z",
     "start_time": "2017-05-08T21:57:52.835278Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from nolearn.dbn import DBN\n",
    "\n",
    "input_dim = 122\n",
    "intermediate_dim = 10\n",
    "latent_dim = 32\n",
    "batch_size = 1409\n",
    "hidden_layers = 8\n",
    "classes = 2\n",
    "drop_prob = 0.2\n",
    "timesteps = 1\n",
    "\n",
    "class Train:\n",
    "    def build_lstm_model(X_train):\n",
    "        Train.x = Input(shape=(timesteps, input_dim))\n",
    "        encoded = LSTM(latent_dim)(Train.x)\n",
    "        \n",
    "        decoded = RepeatVector(timesteps)(encoded)\n",
    "        Train.y = LSTM(classes, return_sequences=True)(decoded)\n",
    "        \n",
    "        clf = DBN(\n",
    "                    [X_train.shape[1], 300, 10],\n",
    "                    learn_rates=0.3,\n",
    "                    learn_rate_decays=0.9,\n",
    "                    epochs=10,\n",
    "                    verbose=1,\n",
    "                )\n",
    "\n",
    "\n",
    "Train.build_lstm_model()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T22:02:53.454683Z",
     "start_time": "2017-05-08T22:01:15.890365Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:2 features count:4\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.4641 - acc: 0.3800 - val_loss: 1.0248 - val_acc: 0.3802\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 0s - loss: 2.4112 - acc: 0.5941 - val_loss: 1.8572 - val_acc: 0.5476\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 2.1326 - acc: 0.5220 - val_loss: 1.3698 - val_acc: 0.4876\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.3263 - acc: 0.5303 - val_loss: 1.3992 - val_acc: 0.3769\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2813 - acc: 0.3823 - val_loss: 1.4164 - val_acc: 0.3478\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.36053938791155815, Test Acc: 0.3478087317198515\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:2 features count:16\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.2067 - acc: 0.3820 - val_loss: 1.3160 - val_acc: 0.3490\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.9477 - acc: 0.5824 - val_loss: 1.1828 - val_acc: 0.6031\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.9461 - acc: 0.4960 - val_loss: 1.0378 - val_acc: 0.4139\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.0320 - acc: 0.4873 - val_loss: 1.0699 - val_acc: 0.6309\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.1610 - acc: 0.6286 - val_loss: 1.2914 - val_acc: 0.4756\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.5172107890248299, Test Acc: 0.475603261962533\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:2 features count:32\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.3332 - acc: 0.6460 - val_loss: 1.2293 - val_acc: 0.3503\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.3980 - acc: 0.5946 - val_loss: 1.3357 - val_acc: 0.3834\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.3772 - acc: 0.6088 - val_loss: 1.4706 - val_acc: 0.3779\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.3465 - acc: 0.4797 - val_loss: 1.5584 - val_acc: 0.4921\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2662 - acc: 0.5459 - val_loss: 1.4969 - val_acc: 0.3645\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.4393186643719673, Test Acc: 0.36453158035874367\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:4 features count:4\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.2749 - acc: 0.4945 - val_loss: 2.0869 - val_acc: 0.6469\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.0038 - acc: 0.6326 - val_loss: 1.6330 - val_acc: 0.3981\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.9638 - acc: 0.6259 - val_loss: 2.1587 - val_acc: 0.6177\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.9849 - acc: 0.5885 - val_loss: 1.7566 - val_acc: 0.5338\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.0884 - acc: 0.5783 - val_loss: 1.8359 - val_acc: 0.5933\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.6379524543881416, Test Acc: 0.5932842493057251\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:4 features count:16\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 0.9974 - acc: 0.4780 - val_loss: 1.8067 - val_acc: 0.4911\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.0954 - acc: 0.4796 - val_loss: 1.7547 - val_acc: 0.5131\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2057 - acc: 0.5915 - val_loss: 1.6918 - val_acc: 0.4977\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2615 - acc: 0.5567 - val_loss: 1.7361 - val_acc: 0.5539\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.3334 - acc: 0.5586 - val_loss: 1.7497 - val_acc: 0.3946\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.43541518598794937, Test Acc: 0.3945617415010929\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:4 features count:32\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.2899 - acc: 0.4899 - val_loss: 2.0035 - val_acc: 0.6129\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2513 - acc: 0.4567 - val_loss: 1.9046 - val_acc: 0.4340\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2136 - acc: 0.3553 - val_loss: 1.9023 - val_acc: 0.4178\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2193 - acc: 0.4104 - val_loss: 1.9938 - val_acc: 0.4592\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2120 - acc: 0.3580 - val_loss: 1.9567 - val_acc: 0.3889\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.31085876375436783, Test Acc: 0.3889283165335655\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:6 features count:4\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.2386 - acc: 0.3590 - val_loss: 2.2186 - val_acc: 0.3480\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.1973 - acc: 0.5448 - val_loss: 2.4204 - val_acc: 0.5747\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.2082 - acc: 0.5077 - val_loss: 2.3045 - val_acc: 0.4374\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.1804 - acc: 0.4586 - val_loss: 2.2869 - val_acc: 0.4348\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.1588 - acc: 0.5310 - val_loss: 2.3507 - val_acc: 0.5582\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.5840134769678116, Test Acc: 0.5581529401242733\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:6 features count:16\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 2s - loss: 1.1587 - acc: 0.6904 - val_loss: 2.4666 - val_acc: 0.6243\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 1.1067 - acc: 0.6812 - val_loss: 2.3738 - val_acc: 0.5925\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.9486 - acc: 0.5837 - val_loss: 2.2907 - val_acc: 0.5720\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.7938 - acc: 0.5653 - val_loss: 2.4171 - val_acc: 0.5721\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.7901 - acc: 0.5580 - val_loss: 2.4938 - val_acc: 0.5702\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.5575762912631035, Test Acc: 0.5701738782227039\n",
      " \n",
      " Current Layer Attributes - epochs:5 hidden layers:6 features count:32\n",
      "Train on 112720 samples, validate on 22544 samples\n",
      "Epoch 1/5\n",
      "112720/112720 [==============================] - 3s - loss: 0.2917 - acc: 0.5748 - val_loss: 2.4110 - val_acc: 0.5888\n",
      "Epoch 2/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.1574 - acc: 0.5860 - val_loss: 2.4123 - val_acc: 0.5833\n",
      "Epoch 3/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.1358 - acc: 0.5829 - val_loss: 2.5204 - val_acc: 0.5858\n",
      "Epoch 4/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.1419 - acc: 0.5896 - val_loss: 2.7127 - val_acc: 0.5897\n",
      "Epoch 5/5\n",
      "112720/112720 [==============================] - 1s - loss: 0.1289 - acc: 0.5939 - val_loss: 2.7496 - val_acc: 0.5900\n",
      "14090/22544 [=================>............] - ETA: 0s\n",
      " Train Acc: 0.5977643728256226, Test Acc: 0.5900017693638802\n"
     ]
    }
   ],
   "source": [
    "import itertools\n",
    "#features_arr = [4, 16, 32, 256, 1024]\n",
    "#hidden_layers_arr = [2, 6, 10, 100]\n",
    "\n",
    "#features_arr = [4, 16, 32]\n",
    "#hidden_layers_arr = [2, 6, 10]\n",
    "\n",
    "features_arr = [4, 16, 32]\n",
    "hidden_layers_arr = [2, 4, 6]\n",
    "\n",
    "epoch_arr = [5]\n",
    "\n",
    "score = namedtuple(\"score\", ['epoch', 'no_of_features','hidden_layers','train_score', 'test_score'])\n",
    "scores = []\n",
    "predictions = {}\n",
    "\n",
    "for e, h, f in itertools.product(epoch_arr, hidden_layers_arr, features_arr):\n",
    "    \n",
    "    print(\" \\n Current Layer Attributes - epochs:{} hidden layers:{} features count:{}\".format(e,h,f))\n",
    "    latent_dim = f\n",
    "    epochs = e\n",
    "    hidden_layers = h\n",
    "    \n",
    "    train_size = x_train.shape[0] - x_train.shape[0]%batch_size\n",
    "    valid_size = x_valid.shape[0] - x_valid.shape[0]%batch_size\n",
    "\n",
    "    \n",
    "    optimizer = keras.optimizers.RMSprop(lr=0.001, rho=0.9, epsilon=1e-08, decay=0.01)\n",
    "    \n",
    "    seq2seq_model = Model(Train.x, Train.y)\n",
    "    seq2seq_model.compile(optimizer = optimizer, \n",
    "                      loss = keras.losses.categorical_crossentropy, \n",
    "                      metrics = ['accuracy'])\n",
    "    \n",
    "    seq2seq_model.fit(x = x_train[:train_size,np.newaxis,:], y = y_train[:train_size,np.newaxis,:],\n",
    "                 shuffle=True, epochs=5, \n",
    "                  batch_size = batch_size, \n",
    "                  validation_data = (x_test[:,np.newaxis,:], y_test[:,np.newaxis,:]),\n",
    "                  verbose = 1)\n",
    "\n",
    "    \n",
    "    score_train = seq2seq_model.evaluate(x_valid[:valid_size,np.newaxis,:], y = y_valid[:valid_size,np.newaxis,:],\n",
    "                               batch_size = batch_size,\n",
    "                               verbose = 1)\n",
    "    \n",
    "    score_test = seq2seq_model.evaluate(x_test[:,np.newaxis,:], y = y_test[:,np.newaxis,:],\n",
    "                           batch_size = batch_size,\n",
    "                           verbose = 1)\n",
    "    \n",
    "    y_test_pred = seq2seq_model.predict(x_test[:,np.newaxis,:], batch_size=batch_size)\n",
    "    y_test_pred = np.squeeze(y_test_pred)\n",
    "\n",
    "    y_pred = y_test_pred #np.argmax(y_test_pred[:,-2:], axis = 1)\n",
    "    \n",
    "    curr_pred = pd.DataFrame({\"Attack_prob\":y_pred[:,0], \"Normal_prob\":y_pred[:,1]})\n",
    "    predictions.update({\"{}_{}_{}\".format(e,f,h):curr_pred})\n",
    "    \n",
    "    scores.append(score(e,f,h,score_train[-1], score_test[-1])) #score_test[-1]))\n",
    "    \n",
    "    print(\"\\n Train Acc: {}, Test Acc: {}\".format(score_train[-1], \n",
    "                                                  score_test[-1])  )\n",
    "    \n",
    "scores = pd.DataFrame(scores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T22:03:31.648220Z",
     "start_time": "2017-05-08T22:03:31.635559Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>epoch</th>\n",
       "      <th>no_of_features</th>\n",
       "      <th>hidden_layers</th>\n",
       "      <th>train_score</th>\n",
       "      <th>test_score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>4</td>\n",
       "      <td>0.637952</td>\n",
       "      <td>0.593284</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5</td>\n",
       "      <td>32</td>\n",
       "      <td>6</td>\n",
       "      <td>0.597764</td>\n",
       "      <td>0.590002</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>5</td>\n",
       "      <td>16</td>\n",
       "      <td>6</td>\n",
       "      <td>0.557576</td>\n",
       "      <td>0.570174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "      <td>0.584013</td>\n",
       "      <td>0.558153</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>5</td>\n",
       "      <td>16</td>\n",
       "      <td>2</td>\n",
       "      <td>0.517211</td>\n",
       "      <td>0.475603</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>16</td>\n",
       "      <td>4</td>\n",
       "      <td>0.435415</td>\n",
       "      <td>0.394562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>32</td>\n",
       "      <td>4</td>\n",
       "      <td>0.310859</td>\n",
       "      <td>0.388928</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>32</td>\n",
       "      <td>2</td>\n",
       "      <td>0.439319</td>\n",
       "      <td>0.364532</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>0.360539</td>\n",
       "      <td>0.347809</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   epoch  no_of_features  hidden_layers  train_score  test_score\n",
       "3      5               4              4     0.637952    0.593284\n",
       "8      5              32              6     0.597764    0.590002\n",
       "7      5              16              6     0.557576    0.570174\n",
       "6      5               4              6     0.584013    0.558153\n",
       "1      5              16              2     0.517211    0.475603\n",
       "4      5              16              4     0.435415    0.394562\n",
       "5      5              32              4     0.310859    0.388928\n",
       "2      5              32              2     0.439319    0.364532\n",
       "0      5               4              2     0.360539    0.347809"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "scores.sort_values(\"test_score\", ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T22:05:49.356162Z",
     "start_time": "2017-05-08T22:05:49.345424Z"
    },
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "pd.Panel(predictions).to_pickle(\"dataset/keras_lstm_nsl_kdd_predictions.pkl\")\n",
    "scores.to_pickle(\"dataset/keras_lstm_nsl_kdd_scores.pkl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2017-05-08T22:04:32.111938Z",
     "start_time": "2017-05-08T22:04:32.105215Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<class 'pandas.core.panel.Panel'>\n",
       "Dimensions: 9 (items) x 22544 (major_axis) x 2 (minor_axis)\n",
       "Items axis: 5_16_2 to 5_4_6\n",
       "Major_axis axis: 0 to 22543\n",
       "Minor_axis axis: Attack_prob to Normal_prob"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Panel(predictions)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "_draft": {
   "nbviewer_url": "https://gist.github.com/33dcb1bcf3ca4a3461c4405a003a7591"
  },
  "anaconda-cloud": {},
  "gist": {
   "data": {
    "description": "Final Hyper parameter tuning",
    "public": false
   },
   "id": "33dcb1bcf3ca4a3461c4405a003a7591"
  },
  "kernelspec": {
   "display_name": "Python [conda env:p2]",
   "language": "python",
   "name": "conda-env-p2-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
